<?php
foreach ($data as $class_name => $class) :
?>
	<h2><?php echo $class_name;?></h2>
	<table>
		<tr>
			<th>№п/п</th>
			<th>ФИО</th>
			<th colspan='2'>Спецкурсы 2012/13 учебный год</th>
			<th>I полугодие</th>
			<th>II полугодие</th>
			<th>Итог</th>
		</tr>
		<?php
		$i = 1;
		foreach ($class as $pupil) :
		?>
		<tr>
			<td rowspan='<?php echo count($pupil['grades']);?>'><?php echo $i++;?></td>
			<td rowspan='<?php echo count($pupil['grades']);?>'><?php echo $pupil['pupil']->get_lastname() . ' ' . $pupil['pupil']->get_name();?></td>
			<?php
			$j = 1;
			foreach ($pupil['grades'] as $grade_for_course) :
			?>
			<td><?php echo $j++;?></td>
			<td><?php echo $grade_for_course['course']?></td>
			<td><?php echo $grade_for_course['grade'][0]->get_grade_text();?></td>
			<td><?php echo $grade_for_course['grade'][1]->get_grade_text();?></td>
			<td><?php echo $grade_for_course['grade'][2]->get_grade_text();?></td>
			</tr><tr>
			<?php
			endforeach;
			?>
		</tr>
		<?php 
		endforeach;
		?>
	</table>
	<p class='page-break'></p>
<?php
endforeach;
?>
